<script setup>
import { clientListService, orderListService, technicianListService } from "@/api/normal";
import { ref } from "vue";

//订单列表模型
const orderData = ref([]);
const clientData = ref([]);
const technicianData = ref([]);

//获取订单列表函数
const orderList = async () => {
  let result = await orderListService();
  orderData.value = result.data;

  clientData.value = await (await clientListService()).data;
  technicianData.value = await (await technicianListService()).data;

  //处理数据
  for (let i = 0; i < orderData.value.length; i++) {
    let order = orderData.value[i];

    for (let j = 0; j < clientData.value.length; j++) {
      if (order.clientId == clientData.value[j].id) {
        order.clientId = clientData.value[j].name;
      }
    }

    for (let j = 0; j < technicianData.value.length; j++) {
      if (order.technicianId == technicianData.value[j].id) {
        order.technicianId = technicianData.value[j].name;
      }
    }
  }
};
orderList();
</script>

<template>
  <el-table :data="orderData" stripe style="width: 100%">
    <el-table-column prop="id" label="编号" width="180" />
    <el-table-column prop="clientId" label="客户" width="180" />
    <el-table-column prop="technicianId" label="技师" width="180" />
    <el-table-column prop="money" label="消费金额" width="180" />
    <el-table-column prop="createTime" label="创建时间" width="180" />
  </el-table>
</template>

<style scoped></style>
